#ifndef STORAGE_STORAGE_COMMAND
#define STORAGE_STORAGE_COMMAND

#include "Storage/CommonStorageConfig.hpp"

namespace Model { class CaseEntity; }

namespace Storage
{

/// \ingroup Storage
/// \brief It is the base class for all the commands describing modifications of the model to be stored.
class COMMON_STORAGE_API StorageCommand
{
public:
	/// \brief It defines the possible storage type commands. 
	///
	/// The command type might give a hint for optimizing the storage. E.g. an insertion followed by a deletion on the 
	///	same case entity might mean that the case entity related storage commands between them will be ignored.
	enum Type
	{
		Create, /// < The command creates the entity in the storage
		Update, /// < The command updates the entity in the storage
		Delete, /// < The command deletes the entity from the storage
		Move	/// < The command moves the entity (the parent is changed)
	};

public:
	/// \brief It initializes the storage command.
	/// \param rSubject the case entity to be stored.
	/// \param type the type of the operation.
	StorageCommand( Model::CaseEntity& rSubject, Type type);

	/// \brief Dummy destructor.
	virtual ~StorageCommand();

	/// \brief To be specialized by the subclasses. It should implement the storage logic specific to the command.
	virtual void execute() = 0;

	/// \brief It gets the type of the command.
	Type type() const { return type_; }

	/// \brief It gets the subject of the command.
	const Model::CaseEntity& subject() const { return rSubject_; }

protected:
	Model::CaseEntity& rSubject_;

private:
	Type type_;
};
	
} // namespace Storage

#endif // STORAGE_STORAGE_COMMAND